package com.czk.businesskey;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.runtime.ProcessInstance;

/**
 * 启动流程实例，添加businessKey
 * @Author ChenZhangKun
 * @Date 2020/9/10 17:19
 */
public class BusinessKeyAdd {
    public static void main(String[] args) {
        ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
        // 得到runtimeServcie
        RuntimeService runtimeService = processEngine.getRuntimeService();
        // 开启流程实例,指定业务标识-》这里本身是启动单的id
        // holiday流程的key,"1"代表的是请假单的id
        ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("holiday", "1001");
        // 输出processInstance相关的属性
        System.out.println("businessKey  "+processInstance.getBusinessKey());
        //
        System.out.println(processEngine.getName());
    }
}
